using UnityEngine;

public class GameManager : MonoSingleton<GameManager>
{

    public LevelManager currLevel;
    public ThemeConfig mainMenuTheme;
    public ThemeConfig[] randThemes;
    public Cargo[] randCargoTypes;

    public Transform audioSpanwRoot;
    public AudioSource audioPlayerPrefab;

    protected override void Awake()
    {
        base.Awake();
        DontDestroyOnLoad(gameObject);
    }

    public ThemeConfig GetRandomTheme()
    {
        int i = Random.Range(0, randThemes.Length);
        return randThemes[i];
    }

    public Cargo GetRandomCargo ()
    {
        int i = Random.Range(0, randCargoTypes.Length);
        return randCargoTypes[i];
    }

    public void PlaySound(AudioClip clip)
    {
        var player = Instantiate(audioPlayerPrefab, audioSpanwRoot);
        player.clip = clip;
        player.Play();
        Destroy(player, Mathf.Min(clip.length * 1.1f, clip.length + 1f));
    }
}
